package warmup.model;

public class Student {
    private String id;
    private String name;
    private int age;

    // 构造方法
    public Student(String id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    // Getter 方法
    public String getId() { return id; }
    public String getName() { return name; }
    public int getAge() { return age; }

    // 重写 toString() 方法
    @Override
    public String toString() {
        return "学号：" + id + "，姓名：" + name + "，年龄：" + age;
    }

    // 重写 equals() 和 hashCode()（根据学号判断是否相同）
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Student student = (Student) obj;
        return id.equals(student.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}